package org.aeon.client.handler.Inbound;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.aeon.client.context.GlobalContext;
import org.aeon.client.view.components.sessionPanel.SessionPanel;
import org.aeon.message.response.GroupQuitResponseMessage;

import javax.swing.*;

/**
 * @author: MissingAeon
 * @date: 2024/3/4 13:28
 * @description:
 */
@Slf4j
@ChannelHandler.Sharable
public class GroupQuitResponseHandler extends SimpleChannelInboundHandler<GroupQuitResponseMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, GroupQuitResponseMessage msg) throws Exception {
        final GlobalContext context = GlobalContext.getContext();
        final SessionPanel sessionPanel = context.getSessionPanel();
        SwingUtilities.invokeLater(() -> {
            sessionPanel.add(sessionPanel.getDefaultPanel());
        });
        ctx.fireChannelRead(msg);
    }
}
